package thread_pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/5/19
 * Time:20:06
 * 创建带缓存的线程池
 **/
public class PoolDemo3 {
    public static void main(String[] args) {
        //创建带缓存的线程池
        ExecutorService service = Executors.newCachedThreadPool();
        //执行10个任务
        for (int i = 0; i < 10; i++) {
            service.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println("线程名称"+Thread.currentThread().getName());
                }
            });
        }
    }
}
